//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../table

block form_items
  .field.three.wide
    .ui.labeled.dropdown.selection.input
      input(type="hidden" name="engine" value="#{engine || ''}")
      i.icon.dropdown
      .default.text 所有引擎
      .menu
        .item(data-value="") 所有引擎
        .item(data-value="1") 1. LUA
        .item(data-value="2") 2. BASH
        .item(data-value="3") 3. PYTHON
        .item(data-value="4") 4. RUBY
        .item(data-value="5") 5. PERL

  .field.two.wide
    .ui.labeled.dropdown.selection.input
      input(type="hidden" name="status" value="#{status || ''}")
      i.icon.dropdown
      .default.text 所有状态
      .menu
        .item(data-value="") 所有状态
        .item(data-value="0") 0. 未启用
        .item(data-value="1") 1. 已启用


  .field.eight.wide
    if page_perms.new
      button#new.ui.right.floated.green.left.icon.labeled.button(type="button"
        onclick="window.location = '/sched/new'") 新 增
        i.icon.plus
    else
      button#new.ui.right.floated.green.icon.button.disabled(type="button")
        i.icon.ban(style="margin-top:1px; margin-right:2px;")
        | 新 增

block thead
  tr
    th.center.aligned 序号
    th.center.aligned 任务名称
    th.center.aligned 创建时间
    th.center.aligned 引 擎
    th.center.aligned CRON 表达式
    th.center.aligned 脚本文件
    th.center.aligned 调度
    th.center.aligned 调度数
    th.center.aligned 最后调度时间
    th.center.aligned 备 注

block tbody
  each record, index in records
    tr
      td.collapsing.center.aligned
        if page_perms.edit || page_perms.disable
          a(href="/sched/edit/#{record.serial}")= record.serial
        else
          = record.serial
      td.collapsing.center.aligned= record.name
      td.collapsing.center.aligned= record.ctime.format('YYYY-MM-DD HH:mm:ss')
      td.collapsing.center.aligned
        case record.engine
          when 1: | LUA
          when 2: | BASH
          when 3: | PYTHON
          when 4: | RUBY
          when 5: | PERL
          default: | 未知
      td.collapsing.center.aligned
        code= record.cron
      td.collapsing.center.aligned
        code= record.script
      td.collapsing.center.aligned
        case record.status
          when 0
            i.icon.remove.red
          when 1
            i.icon.checkmark.green
          default
            i.icon.question.red
      td.collapsing.center.aligned= record.sched_cnt
      td.collapsing.center.aligned= record.last_sched.format('YYYY-MM-DD HH:mm:ss')
      td= record.notes
